import 'package:audioplayers/audioplayers.dart';

enum FeedbackType { correct, incorrect }

class AudioFeedback {
  final AudioPlayer _audioPlayer = AudioPlayer();

  Future<void> playFeedback(FeedbackType type) async {
    try {
      final String fileName = _getAudioFileName(type);
      await _audioPlayer?.play(AssetSource(fileName));
    } catch (e) {
      print('Error playing sound: $e');
    }
  }

  String _getAudioFileName(FeedbackType type) {
    return 'audio/${type == FeedbackType.correct ? 'taibang.mp3' : 'oo.mp3'}';
  }

  void dispose() {
    _audioPlayer.dispose();
  }
}